package com.jy.rhin.infra.repo.notfication.topic.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jy.rhin.domain.notification.topic.entity.TopicDO;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author WeiQ
 * @date 2022/6/28 16:07
 * 主题信息
 */
@Data
@TableName("t_notification_topic")
@NoArgsConstructor
public class TopicPO {

    public TopicPO(TopicDO topic) {
        this.id = topic.getId();
        this.publisherCode = topic.getPublisherCode();
        this.topicName = topic.getTopicName();
        this.topicExp = topic.getTopicExp();
        this.topicDesc = topic.getTopicDesc();
        this.createTime = topic.getCreateTime();
    }

    public TopicDO toDO() {
        TopicDO topic = new TopicDO();
        topic.setId(this.id);
        topic.setPublisherCode(this.publisherCode);
        topic.setTopicName(this.topicName);
        topic.setTopicExp(this.topicExp);
        topic.setTopicDesc(this.topicDesc);
        topic.setCreateTime(this.createTime);
        return topic;
    }

    @TableId
    private Long id;
    /**
     * 发布者代码
     */
    @TableField("publisher_code")
    private String publisherCode;
    /**
     * 主题名称
     */
    @TableField("topic_name")
    private String topicName;
    /**
     * 主题表达式
     */
    @TableField("topic_exp")
    private String topicExp;
    /**
     * 主题描述
     */
    @TableField("topic_desc")
    private String topicDesc;
    /**
     * 创建时间
     */
    @TableField("create_time")
    private Date createTime;

}
